import { createRouter, createWebHistory } from 'vue-router'
import { ROUTES, ROUTE_NAMES } from '@/constants/routes.js'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: ROUTES.LOGIN,
      name: ROUTE_NAMES.LOGIN,
      component: () => import('../components/common/login/login.vue')
    },
    {
      path: ROUTES.HARDCODE_WEB,
      component: () => import('../layouts/pc/layout.vue'),
      children: [
        {
          path: ROUTES.BLANK.substring(1),
          name: ROUTE_NAMES.PC_BLANK,
          component: () => import('../components/common/blank/blank.vue')
        },
        {
          path: ROUTES.RENDER.substring(1),
          name: ROUTE_NAMES.PC_RENDER,
          component: import('../components/pc/render/render.vue')
        },
        {
          path: ROUTES.ERROR404.substring(1),
          name: ROUTE_NAMES.PC_ERROR404,
          component: () => import('../components/common/error404/error404.vue')
        },
        {
          path: ROUTES.PERSONAL_SETTINGS.substring(1),
          name: ROUTE_NAMES.PC_PERSONAL_SETTINGS,
          component: () => import('../components/pc/personal-settings/personal-settings.vue')
        },
        {
          path: ROUTES.HARDCODE_MWEB + ROUTES.SEARCH.substring(1),
          name: ROUTE_NAMES.MOBILE_SEARCH,
          component: () => import('../components/mobile/search/search.vue')
        }
      ]
    }]
})


import { loadDynamicPages, loadDevPages } from '../pages/loadPages.js';

if (import.meta.env.NODE_ENV === 'production') {

  loadDynamicPages(router, import.meta.env.VITE_APP_CODE);
} else {
  loadDevPages(router, import.meta.env.VITE_APP_CODE);
}

export default router
